﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RayDen.Library.Components.Color.Types;
using RayDen.Library.Components.Surface;
using RayDen.Library.Core;
using RayDen.Library.Core.Primitives;
using RayDen.RayEngine.Samplers;
using RayEngine.Spectral.Entities.Materials;

namespace RayEngine.Spectral.Entities
{
    public enum ShadePointType
    {
        Environment,
        Surface,
        Volume,
        Light,
    }

    public class ShadePointInfo
    {
        public Point HitPoint;
        public float U, V;
        public Normal GeoNormal, ShadingNormal;
        public UV TexCoord;
        public ONB Frame;
        public ShadePointType PointType;

        public Vector IncomingDirection;
        public float IncomingDistance, Wavelength;

        public int ObjectId, ElementIndex;

        public BrdfBase Brdf;

        public IColorType Diffuse;
        public IColorType Specular;
        public IColorType Absorbance;
        public IColorType Glossy;
        public IColorType Transmittance;
        public float IndexOfRefraction, Exponent;

        public IColorType GetColor()
        {
            switch (Brdf.Type)
            {                
                case BrdfType.Glossy:
                    return Glossy.CloneValue();
                case BrdfType.Specular:
                    return Specular.CloneValue();
                case BrdfType.Refractive:
                    return Transmittance.CloneValue();
            }
            return Diffuse.CloneValue();
        }


        public IColorType GetColorInstance()
        {
            switch (Brdf.Type)
            {
                case BrdfType.Glossy:
                    return Glossy;
                case BrdfType.Specular:
                    return Specular;
                case BrdfType.Refractive:
                    return Transmittance;
            }
            return Diffuse;
        }
    }
}
